//
//  ShareVC.m
//  BrushFace
//
//  Created by timer_q on 16/1/25.
//  Copyright © 2016年 Zzz. All rights reserved.
//

#import "ShareVC.h"
#import "WeChat.h"
#import "MySceneModel.h"
@interface ShareVC ()
{
    NSString *_shareTitle;
    UIImageView *_shareImageView;
}
@property (nonatomic,strong)MySceneModel *reqModel;
@end

@implementation ShareVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self.navBar setTitle:@"添加微信好友"];
    _shareTitle = @"我是刷脸，点击这里在刷脸和我成为朋友吧!";
    _shareImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 120, 120)];
    _shareImageView.hidden = YES;
    [self.navBar setLeftBtn:NAV_BAR_LEFT_BTN_TYPE_BLUE];
    _reqModel = [MySceneModel SceneModel];
    [_reqModel user_getMyIndexForAppAndCB:^(id output) {
        //NSLog(@"%@",output);
        _shareTitle = [NSString stringWithFormat:@"我是%@，点击这里在刷脸和我成为朋友吧!",output[@"fullname"]];
        [_shareImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",HEADERIMAGE_FETCH,output[@"userid"]]]];
    }];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)shareToWeChatButtonClick:(id)sender {
    
    WXMediaMessage *message = [WXMediaMessage message];
    message.title = _shareTitle;
    message.description = @"熟人借贷，就是刷脸。现在注册立得120元大礼包！";
    
    [message setThumbImage:_shareImageView.image];
    
    WXWebpageObject *ext = [WXWebpageObject object];
    ext.webpageUrl = @"http://www.baidu.com";
    message.mediaObject = ext;
    SendMessageToWXReq* req = [[SendMessageToWXReq alloc] init];
    req.bText = NO;
    req.message = message;
    req.scene = WXSceneSession;
    [WXApi sendReq:req];
}
- (IBAction)shareToTimeLineButtonClick:(id)sender {
    WXMediaMessage *message = [WXMediaMessage message];
    message.title = _shareTitle;
    message.description = @"熟人借贷，就是刷脸。现在注册立得120元大礼包！";
    
    [message setThumbImage:_shareImageView.image];
    
    WXWebpageObject *ext = [WXWebpageObject object];
    ext.webpageUrl = @"http://www.baidu.com";
    message.mediaObject = ext;
    SendMessageToWXReq* req = [[SendMessageToWXReq alloc] init];
    req.bText = NO;
    req.message = message;
    req.scene = WXSceneTimeline;
    [WXApi sendReq:req];
}

@end
